package cn.xiaohuodui.dao;

import cn.xiaohuodui.model.Session;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface SessionMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Session record);

    int insertSelective(Session record);

    Session selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Session record);

    int updateByPrimaryKey(Session record);


    Session selectByUidAndExpired(@Param("uid") int uid, @Param("expired") long expired);

    /**
     * 获取用户的最后一次登录Session
     *
     * @param uid
     * @return
     */
    Session selectLastSession(@Param("uid") int uid);

    /**
     * 设置 ${sessionId} 该session 为过期了
     *
     * @param sessionId
     * @param expired
     * @return
     */
    int setExpiredBySessionId(@Param("sessionId") int sessionId, @Param("expired") long expired);
}